package com.haodai.agency.base;

import com.haodai.agency.bean.DeletePictureBean;
import com.haodai.agency.net.MyObserver;
import com.haodai.agency.net.NetUtils;
import com.haodai.agency.net.RetrofitUtils;
import com.haodai.agency.net.bean.ResultEntity;
import com.haodai.agency.save.SaveSharedPreferences;

import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;
import rx.Observable;
import rx.Observer;

/**
 * Created by 张志浩 on 2017/3/11.
 *
 * 公用接口汇集区域
 */
public class BaseNetService extends RetrofitUtils {

    private static final NetService service = getRetrofit().create(NetService.class);

    private interface NetService{

        @FormUrlEncoded
        @POST("Login/getCode")//获取验证码
        Observable<ResultEntity<String>> getCode(@Field("data") String data);

        @FormUrlEncoded
        @POST("Login/updatePwd")//修改密码
        Observable<ResultEntity<String>> updatePwd(@Field("data") String data);

        @FormUrlEncoded
        @POST("Login/forgetPwd")//忘记密码
        Observable<ResultEntity<String>> forgetPwd(@Field("data") String data);

        @FormUrlEncoded
        @POST("Order/delOrderImage")//
        Observable<ResultEntity<String>> delOrderImage(@Field("data") String data);

        @FormUrlEncoded
        @POST("UpdateApp/androidUpdate")//版本更新
        Observable<ResultEntity<String>> androidUpdate(@Field("data") String data);

        //暂时存放位置 产品
        @FormUrlEncoded
        @POST  ("Product/getProductDetail")//产品详情
        Observable<ResultEntity<String>> getProductDetail(@Field("data") String data);

        @FormUrlEncoded
        @POST  ("Product/isBindProduct")//是否有产品
        Observable<ResultEntity<String>> isBindProduct(@Field("data") String data);

    }

    //获取验证码
    public static void getCode(String data, MyObserver<String> observer){
        NetUtils.setSubscribe(service.getCode(data),observer.creatObserver());
    }
    //修改密码
    public static void updatePwd(String data, MyObserver<String> observer){
        NetUtils.setSubscribe(service.updatePwd(data),observer.creatObserver());
    }
    //修改密码
    public static void forgetPwd(String data, MyObserver<String> observer){
        NetUtils.setSubscribe(service.forgetPwd(data),observer.creatObserver());
    }

    //删除图片
    public static void delOrderImage(String data, MyObserver<DeletePictureBean> observer){
        NetUtils.setSubscribe(service.delOrderImage(data),observer.creatObserver());
    }

    //产品详情
    public static void getProductDetail(String data, MyObserver<ResultEntity<String>> observer){
        NetUtils.setSubscribe(service.getProductDetail(data),observer.creatObserver());
    }

    //是否有产品
    public static void isBindProduct( MyObserver<ResultEntity<String>> observer){
        NetUtils.setSubscribe(service.isBindProduct("{}"),observer.creatObserver());
    }

    //版本更新内容
    public static void androidUpdate(MyObserver<ResultEntity<String>> observer){
        NetUtils.setSubscribe(service.androidUpdate("{}"),observer.creatObserver());
    }
}
